#include<bits/stdc++.h>
using namespace std;
int a,b,c[100001],f[10001],m,v;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
freopen("x.in","r",stdin);
freopen("x.out","w",stdout);
cin>>a;
for(int i=1;i<=a;i++){
cin>>b;
for(int j=0;j<b;j++)
cin>>c[j];
do{
  for(int z=0;z<b;z=z+2){
  f[z]=1;
  f[z+1]=0;
  }
  v=b;
  for(int z=0;z<b;z++){
  if(c[z]=c[v]&&f[z]==f[v])m=m+c[z];
  v--;
  }
  cout<<m;
}while(next_permutation(c,c+b));}
return 0;
}
